#ifndef _FENGINE_BILLBOARD_
#define _FENGINE_BILLBOARD_

#include <vector>
#include "CoreEngine.h"
#include "FEngineType.h"
#include "Node.h"

namespace FEngine
{
	/**
	 * A billboard if a quad with a texture always facing the camera.
	 * The Node method to change the rotation is (obviously) not effective on a billboard.
	 */
	class Billboard : public Node
	{

		public:
			
			/**
			 * Constructor.
			 * @param _pos World position of the billboard.
			 * @param _scale Scale f the billboard (default size if (1, 1, 1))
			 * @param _textureName Name of the texture file of the mesh.
			 * @param _windForce Amplitude of the wave movement of the billboard.
			 * @param _windOffset Offset of the movement of the grass under the wind.
			 */
			Billboard(Vector3 _pos, Vector3 _scale, const std::string& _textureName, float _windForce, float _windOffset);
			/**
			 * Constructor.
			 * @param _pos World position of the billboard.
			 * @param _scale Scale f the billboard (default size if (1, 1, 1))
			 * @param _texture Texture of the mesh.
			 * @param _windForce Amplitude of the wave movement of the billboard.
			 * @param _windOffset Offset of the movement of the grass under the wind.
			 */
			Billboard(Vector3 _pos, Vector3 _scale, LPDIRECT3DTEXTURE9 _texture, float _windForce, float _windOffset);
			virtual ~Billboard();

			virtual void update(double _elapsedTime);
			virtual void render(double _elapsedTime);

			
		protected:

			LPDIRECT3DVERTEXBUFFER9			mVertexBuffer;
			IDirect3DVertexDeclaration9*	mVertexDeclaration;
			LPDIRECT3DINDEXBUFFER9			mIndexBuffer;
			
			int								mNumberVertices;
			int								mNumberPrimitives;

			LPDIRECT3DTEXTURE9				mMeshTexture;
			bool							mIsTexturePreLoaded;	// Indicate if the texture was already loaded at the creation

			Vector3							mBillboardPosition;
			Vector3							mBillboardScale;
			float							mWindForce;			// Amplitude of the movement of the grass under the wind
			float							mWindOffset;		// Offset in the movement of the grass
			
			virtual void _createGeometry();
			void _loadTexture(const std::string& _textureName);
	};

} // namespace FEngine

#endif
